import QtQuick 2.0
import "./Custom"

ScreenBase{
    id: bg2
    anchors.fill: parent
    source: "qrc:/images/bg2.png"

    property alias seq: seq
    property real process: 0

    signal loadfinish()

    onShowfinish: {
        // start load
        bg2.seq.restart()
    }

    onHidefinish: {
        t1.opacity = 0.0
        t2.opacity = 0.0
        t3.opacity = 0.0
    }

    Column{
        spacing: 5
        anchors.right: parent.right
        anchors.rightMargin: 100
        anchors.verticalCenter: parent.verticalCenter
        height: t1.height*3 + spacing*2

        TextBase {
            id: t1
            color: "black"
            font.pixelSize: 10
            text: "盘古正在写代码"
            opacity: 0
        }
        TextBase {
            id: t2
            color: "black"
            font.pixelSize: t1.font.pixelSize
            text: "正在生成秘境1个"
            opacity: 0
        }
        TextBase {
            id: t3
            color: "black"
            font.pixelSize: t1.font.pixelSize
            text: "正在进入八荒"
            opacity: 0
        }
    }

    ParallelAnimation{
        id: seq
        SequentialAnimation{
            PropertyAnimation{target: t1; property: "opacity"; to: 1.0; duration: 1000; }
            PropertyAnimation{target: t2; property: "opacity"; to: 1.0; duration: 1000; }
            PropertyAnimation{target: t3; property: "opacity"; to: 1.0; duration: 1000; }

            PauseAnimation {
                duration: 1000
            }
        }
        SequentialAnimation{
            PropertyAnimation{target: bg2; property: "process"; from: 0.0; to: 1.0; duration: 3000; }
        }
        onStopped: {
            bg2.hide()
            loadfinish()
        }
    }

    Rectangle{
        width: 300
        height: 5
        color: Qt.rgba(64/255, 65/255, 70/255, 1.0)
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 20

        Rectangle{
            width: parent.width * bg2.process
            height: 5
            color: Qt.rgba(78/255, 191/255, 173/255, 1.0)
        }
    }
}
